home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / play / multiplsr.lha / dssplay.asm < prev    next >
Assembly Source File  |  1992-09-14  |  20KB  |  720 lines

  1. * MultiPlayer
  2. * Copyright (C) 1992 Bryan Ford
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * See Player.doc for info on contacting the author.
  19. *
  20. * Note:  This playroutine was not originally written by me.  In general
  21. * these playroutines are public domain, so I am bringing the versions
  22. * modified for MultiPlayer under the General Public License.  In the
  23. * few cases of already-copyrighted playroutines, the above copyright
  24. * notice applies only to the parts of the file written by me.
  25. *
  26. * $Id: dssplay.asm,v 4.1 92/07/12 10:40:43 BAF Exp $
  27. *
  28.  
  29.         include "player.i"
  30.  
  31.         code    text
  32.  
  33.         xref    modmem,dmawait
  34.  
  35.         xdef    dssstart
  36.  
  37. dssstart:
  38.         plstartret .gmod
  39.  
  40.         cnop    0,4
  41.         dc.l    gmod_Hook
  42. .gmod
  43.         gmodnop
  44.         gmodbra InitPlay                ; StartMusic
  45.         gmodbra RemovePlayer            ; StopMusic
  46.         gmodnop
  47.         gmodnop
  48.         gmodnop
  49.         gmodnop
  50.         gmodnop
  51.         gmodnop
  52.         gmodnop
  53.         gmodnop
  54.         gmodnop
  55.         gmodnop
  56.         gmodnop
  57.         gmodnop
  58.         gmodnop                         ; GetFrequency
  59.         gmodnop                         ; TimerTick
  60.         lea     name(a4),a0             ; GetMakerName
  61.         move.l  a0,d0
  62.         rts
  63.  
  64.  
  65. ;**************************************************************************
  66. ;*
  67. ;*   DSS MODULE PLAY ROUTINE
  68. ;*   -----------------------
  69. ;*
  70. ;*   If you wish to use some DSS Tracker Modules into your own programs,
  71. ;*   you can read the following listing...
  72. ;*
  73. ;*   This file contains the needed functions for playing a DSS Module.
  74. ;*   You have to allocate, to load  and to free the memory (CHIP) yourself.
  75. ;*
  76. ;*  >Once the Module is loaded in CHIP memory:
  77. ;*
  78. ;*   -Set the [ SongPointer ] pointer (at the end of this file) with the
  79. ;*    Module's address.
  80. ;*   -Call the [ InitPlay() ] function.
  81. ;*
  82. ;*  >To stop the Module, you just have to call the [ RemovePlayer() ]
  83. ;*   function.
  84. ;*
  85. ;*   This program has been writen for the Aztec C 3.6 assembler.
  86. ;*   It can be easily adapted to another assembler.
  87. ;*
  88. ;**************************************************************************
  89.  
  90. ;----- Amiga function ------
  91.  
  92. _LVOOpenResource        EQU        -498
  93. _LVOAddICRVector        EQU        -6
  94. _LVORemICRVector        EQU        -12
  95.  
  96. ;------- ExecBase ----
  97.  
  98. SysBase                 EQU     4
  99. PAL                     EQU     50
  100. eb_PowerSupplyFreq      EQU     531
  101.  
  102. ;------- CIAA --------
  103.  
  104. CIAAPRA         EQU     $bfe001
  105. CIABTALO        EQU     $bfd400
  106. CIABTAHI        EQU     $bfd500
  107. CIABICR         EQU     $bfdd00
  108. CIABCRA         EQU     $bfde00
  109.  
  110. CIABTBLO        EQU     $bfd600
  111. CIABTBHI        EQU     $bfd700
  112. CIABCRB         EQU     $bfdf00
  113.  
  114. ;------ Song ----------
  115.  
  116. sng_Tempo       EQU     8
  117. sng_Instr0      EQU     10
  118. sng_Len         EQU     1436
  119. sng_Seq         EQU     1438
  120. sng_Data        EQU     1566
  121.  
  122. ;------ InstrData -----
  123.  
  124. MAXINSTR        EQU     30
  125. SIZEOF_insdt    EQU     46
  126.  
  127. instr_Name      EQU     0
  128. instr_Start     EQU     30
  129. instr_Len       EQU     34
  130. instr_RStart    EQU     36
  131. instr_RLen      EQU     40
  132. instr_Vol       EQU     42
  133. instr_Freq      EQU     44
  134.  
  135. ;------- AudioData -
  136.  
  137. SIZEOF_ad       EQU     24
  138.  
  139. ad_SampPer      EQU     0
  140. ad_Effet        EQU     2
  141. ad_Info         EQU     3
  142. ad_Volume       EQU     4
  143. ad_SmpAdr       EQU     6
  144. ad_SmpLen       EQU     10
  145. ad_RepAdr       EQU     12
  146. ad_RepLen       EQU     16
  147. ad_ArpPer       EQU     18
  148. ad_DMABit       EQU     20
  149. ad_PitchPer     EQU     22
  150.  
  151. ;------- AudioChips -------
  152.  
  153. DMACON          EQU     $dff096
  154. DMASET          EQU     $8000
  155.  
  156. AUD0LCH         EQU     $dff0a0
  157. AUD1LCH         EQU     $dff0b0
  158. AUD2LCH         EQU     $dff0c0
  159. AUD3LCH         EQU     $dff0d0
  160. AUDxLEN         EQU     $4
  161. AUDxPER         EQU     $6
  162. AUDxVOL         EQU     $8
  163. AUDxDAT         EQU     $a
  164. SIZEOF_AUD      EQU     $10
  165.  
  166. ;------ Block ---------
  167.  
  168. NEXTTRACK       EQU     4
  169. NEXTLINE        EQU     16
  170. BLOCKSIZE       EQU     1024
  171. MAXTRACK        EQU     4
  172.  
  173. ;------- Notes -------
  174.  
  175. DO2             EQU     1712
  176. SI5             EQU     113
  177. STOP            EQU     $7ff
  178.  
  179. ;------- Effects -----
  180.  
  181. MASK_EFF        EQU     7
  182. MASK_VAL        EQU     $f
  183.  
  184. ARPEGGIO        EQU     0
  185. PITCHUP         EQU     1
  186. PITCHDOWN       EQU     2
  187. VOLUME          EQU     3
  188. MASTERVOL       EQU     4
  189. TEMPO           EQU     5
  190. JUMP            EQU     6
  191. FILTER          EQU     7
  192.  
  193. MAX_VOL         EQU     64
  194. BREAK           EQU     $ff
  195.  
  196.  
  197. ;------------------ functions to call -----------------
  198.  
  199. ; Timer interruption installation and Player initialization routines
  200. ; Return 0 (zero) if successful.
  201. ; Return 1 if the installation is not possible.
  202.  
  203. InitPlay:
  204.         lea     clrstart,a0
  205.         moveq   #(clrend-clrstart)/2-1,d0
  206. .clr
  207.         clr.w   (a0)+
  208.         dbra    d0,.clr
  209.  
  210.         movem.l d1-d2/a0-a3/a6,-(sp)
  211.         move.l  SysBase,a6
  212.         lea     CiabName,a1
  213.         moveq   #0,d0
  214.         jsr     _LVOOpenResource(a6)
  215.         move.l  d0,CiabBase
  216.         beq.s   InitPlayError
  217.         cmp.b   #PAL,eb_PowerSupplyFreq(a6)
  218.         beq.s   initsong
  219.         move.w  #2,IsNTSC
  220. initsong:
  221.         bsr     InitSampleAdr
  222.         bsr     InitSamples
  223.         bsr     InitInterrupt
  224.         tst.l   d0
  225.         beq     EndInitPlay
  226. InitPlayError:
  227.         moveq   #1,d0
  228. EndInitPlay:
  229.         movem.l (sp)+,d1-d2/a0-a3/a6
  230.         rts
  231.  
  232. ; Stop to play the module
  233.  
  234. RemovePlayer:
  235.         movem.l d0-d1/a0-a1/a6,-(sp)
  236.         bsr     DisablePlayer
  237.         move.l  CiabBase,a6
  238.         lea     TimerInt,a1
  239.         moveq   #1,d0
  240.         jsr     _LVORemICRVector(a6)
  241.         bclr    #1,CIAAPRA
  242.         movem.l (sp)+,d0-d1/a0-a1/a6
  243.         rts
  244.  
  245. ;-------------- internal functions -----------------
  246.  
  247. InitInterrupt:
  248.         bsr     EnablePlayer
  249.         move.l  CiabBase,a6
  250.         lea     TimerInt,a1
  251.         moveq   #1,d0
  252.         jsr     _LVOAddICRVector(a6)
  253.         tst.l   d0
  254.         bne.s   InitInterruptEnd
  255.         move.b  CIABCRB,d0
  256.         and.b   #%10000000,d0
  257.         or.b    #1,d0
  258.         move.b  d0,CIABCRB
  259.         move.b  #$82,CIABICR
  260.         lea     TimerTable,a0
  261.         move.w  IsNTSC,d0
  262.         move.b  1(a0,d0),CIABTBLO
  263.         move.b  0(a0,d0),CIABTBHI
  264.         moveq   #0,d0
  265. InitInterruptEnd:
  266.         rts
  267.  
  268. InitSampleAdr:
  269.         move.l  modmem,a1
  270.         lea     sng_Len(a1),a0
  271.         move.w  (a0)+,d0                ; d0 = songlen
  272.         subq.w  #1,d0
  273.         moveq   #0,d1
  274.         move.l  d1,d2
  275. SeekLastBlockLoop:
  276.         move.b  (a0)+,d2
  277.         cmp.b   d2,d1
  278.         bhi.s   NotLastBlock
  279.         move.b  d2,d1
  280. NotLastBlock:
  281.         dbra    d0,SeekLastBlockLoop
  282.         addq.w  #1,d1
  283.         moveq   #10,d0
  284.         lsl.l   d0,d1                   ; d1 = block size
  285.         lea     sng_Data(a1),a0
  286.         add.l   d1,a0                   ; a0 -> first sample
  287.         lea     sng_Instr0(a1),a2       ; a2 -> first instrument
  288.         lea     SampleAdrTable,a3
  289.         moveq   #MAXINSTR,d0
  290. InitAdrLoop:
  291.         moveq   #0,d1
  292.         move.w  instr_Len(a2),d1        ; len ?
  293.         beq.s   InitNextAdr
  294. InitThisAdr:
  295.         move.l  a0,(a3)
  296.         moveq   #0,d2
  297.         cmp.w   #1,instr_RLen(a2)       ; rlen
  298.         beq.s   GetSampleSize
  299.         move.w  instr_RLen(a2),d2
  300.         add.l   d2,d1
  301. GetSampleSize:
  302.         add.l   d1,d1
  303.         bclr    #0,instr_Start+3(a2)    ; align instr_Start on a word
  304.         add.l   instr_Start(a2),d1      ; Start
  305.         add.l   d1,a0                   ; a0 -> nextsample
  306. InitNextAdr:
  307.         addq.l  #4,a3
  308.         add.l   #SIZEOF_insdt,a2
  309.         dbra    d0,InitAdrLoop
  310.         rts
  311.  
  312. InitSamples:
  313.         lea     SampleAdrTable,a0
  314.         moveq   #MAXINSTR,d0
  315. InitSamplesLoop:
  316.         move.l  (a0)+,d1
  317.         beq.s   InitSamplesLoopEnd
  318.         move.l  d1,a1
  319.         moveq   #3,d2
  320. Clear4Bytes:
  321.         clr.b   (a1)+
  322.         dbra    d2,Clear4Bytes
  323. InitSamplesLoopEnd:
  324.         dbra    d0,InitSamplesLoop
  325.         rts
  326.  
  327.  
  328. DisablePlayer:
  329.         clr.w   AUD0LCH+AUDxVOL
  330.         clr.w   AUD1LCH+AUDxVOL
  331.         clr.w   AUD2LCH+AUDxVOL
  332.         clr.w   AUD3LCH+AUDxVOL
  333.         move.w  #$0f,DMACON
  334.         rts
  335.  
  336. EnablePlayer:
  337.         clr.w   AUD0LCH+AUDxVOL
  338.         clr.w   AUD1LCH+AUDxVOL
  339.         clr.w   AUD2LCH+AUDxVOL
  340.         clr.w   AUD3LCH+AUDxVOL
  341.         rts
  342.  
  343. TimerIntRoutine:
  344.         movem.l d1-d7/a0-a6,-(sp)
  345.         bsr.s   PlayRoutine
  346.         movem.l (sp)+,d1-d7/a0-a6
  347.         moveq   #0,d0
  348.         rts
  349.  
  350. PlayRoutine:
  351.         move.l  modmem,a6
  352.         move.w  8(a6),d0
  353.         addq.w  #1,PlayTimer
  354.         cmp.w   PlayTimer,d0            ; tempo == playtimer ?
  355.         bne.s   PlayEffects             ; no, play effects
  356.         clr.w   PlayTimer               ; yes, reset timer to zero
  357.         bra     PlaySound               ; play note
  358.  
  359. PlayEffects:
  360.         lea     ChannelData0,a0
  361.         lea     AUD0LCH,a1
  362.         moveq   #MAXTRACK-1,d3          ; 4 tracks
  363. PlayEffLoop:
  364.         move.w  (a0),d0
  365.         and.w   #$7ff,d0
  366.         cmp.w   #STOP,d0                ; note == STOP ?
  367.         beq.s   PlayEffLoopEnd
  368.         tst.b   ad_Info(a0)             ; effect value == 0 ?
  369.         beq.s   PlayEffLoopEnd
  370.         bsr.s   MakeEffects
  371. PlayEffLoopEnd:
  372.         add.l   #SIZEOF_ad,a0           ; a0 -> next channeldata
  373.         add.w   #SIZEOF_AUD,a1          ; a1 -> next audio register
  374.         dbra    d3,PlayEffLoop
  375.         rts
  376.  
  377. MakeEffects:
  378.         move.b  ad_Effet(a0),d0
  379.         beq.s   EffArpeggio
  380.         cmp.b   #PITCHUP,d0
  381.         beq.s   EffPitchUp
  382.         cmp.b   #PITCHDOWN,d0
  383.         beq.s   EffPitchDown
  384.         rts
  385.  
  386. EffArpeggio:
  387.         moveq   #0,d0
  388.         move.w  PlayTimer,d0
  389.         cmp.w   #1,d0
  390.         beq.s   EffArpOne
  391.         cmp.w   #2,d0
  392.         beq.s   EffArpTwo
  393.         cmp.w   #3,d0
  394.         beq.s   EffArpThree
  395.         cmp.w   #4,d0
  396.         beq.s   EffArpTwo
  397.         cmp.w   #5,d0
  398.         beq.s   EffArpOne
  399.         rts
  400.  
  401. EffArpOne:
  402.         move.b  ad_Info(a0),d0
  403.         lsr.b   #4,d0                   ; d0 = high nibble value
  404.         bra.s   EffArpSeek
  405. EffArpTwo:
  406.         move.b  ad_Info(a0),d0
  407.         and.b   #MASK_VAL,d0            ; d0 = low nibble value
  408.         bra.s   EffArpSeek
  409. EffArpThree:
  410.         move.w  ad_ArpPer(a0),d2        ; d2 = normal period
  411.         bra.s   EffArpFound
  412. EffArpSeek:
  413.         add.w   d0,d0                   ; d0 = offset notetable
  414.         move.w  ad_ArpPer(a0),d1        ; d1 = normal period
  415.         lea     NoteTable,a2
  416. EffArpLoop:
  417.         move.w  0(a2,d0.w),d2           ; d2 = new period
  418.         cmp.w   (a2)+,d1                ; (a2) == normal period
  419.         bne.s   EffArpLoop
  420. EffArpFound:
  421.         move.w  d2,AUDxPER(a1)
  422.         rts
  423.  
  424. EffPitchUp:
  425.         moveq   #0,d0
  426.         move.b  ad_Info(a0),d0          ; d0 = effect value
  427.         sub.w   d0,ad_PitchPer(a0)
  428.         cmp.w   #SI5,ad_PitchPer(a0)    ; less than lowest period ?
  429.         bpl.s   EffPitchOK
  430.         move.w  #SI5,ad_PitchPer(a0)
  431.         bra.s   EffPitchOK
  432. EffPitchDown:
  433.         moveq   #0,d0
  434.         move.b  ad_Info(a0),d0
  435.         add.w   d0,ad_PitchPer(a0)
  436.         cmp.w   #DO2,ad_PitchPer(a0)    ; more than highest period ?
  437.         bmi.s   EffPitchOK
  438.         move.w  #DO2,ad_PitchPer(a0)
  439. EffPitchOK:
  440.         move.w  ad_PitchPer(a0),AUDxPER(a1)
  441.         rts
  442.  
  443. PlaySound:
  444.         lea     sng_Data(a6),a0
  445.         lea     sng_Seq(a6),a1
  446.         move.w  CurrentPos,d0
  447.         move.w  d0,NewPosJump
  448.         moveq   #0,d1
  449.         move.b  0(a1,d0.w),d1           ; d1 = block number
  450.         moveq   #10,d0
  451.         lsl.l   d0,d1
  452.         add.l   OffsetBlock,d1          ; d1 = offset into block data
  453.         clr.w   AudioDMA
  454.  
  455.         lea     AUD0LCH,a3
  456.         lea     ChannelData0,a4
  457.         moveq   #MAXTRACK-1,d7          ; 4 tracks
  458. PlayLoop:
  459.         bsr     PlayInstr
  460.         add.w   #SIZEOF_AUD,a3
  461.         add.l   #SIZEOF_ad,a4
  462.         dbra    d7,PlayLoop
  463.  
  464.         move.w  AudioDMA,d0             ; start audio DMA
  465.         or.w    #DMASET,d0
  466.         move.w  d0,DMACON
  467.  
  468.         move.b  CIABCRA,d1              ; wait loop
  469.         move.b  d1,d0
  470.         and.b   #%11000000,d0
  471.         or.b    #%00001000,d0
  472.         move.b  d0,CIABCRA
  473.         move.b  #$2f,CIABTALO
  474.         move.b  #1,CIABTAHI
  475. PlayDelay1:
  476.         btst.b  #0,CIABCRA
  477.         bne.s   PlayDelay1
  478.         move.b  d1,CIABCRA
  479.         move.b  #%00000001,CIABICR
  480.  
  481.         lea     ChannelData0,a0         ; set new value into audio registers
  482.         lea     AUD0LCH,a1
  483.         moveq   #MAXTRACK-1,d0
  484. SetNewValue:
  485.         move.l  ad_RepAdr(a0),(a1)
  486.         move.w  ad_RepLen(a0),AUDxLEN(a1)
  487.         add.l   #SIZEOF_ad,a0
  488.         add.w   #SIZEOF_AUD,a1
  489.         dbra    d0,SetNewValue
  490.         cmp.l   #BLOCKSIZE-NEXTLINE,OffsetBlock  ; end of block ?
  491.         beq.s   ChangePosition
  492.         add.l   #NEXTLINE,OffsetBlock   ; modif. offsetblock
  493.         tst.w   BreakStatus             ; jump or break ?
  494.         beq.s   PlaySoundEnd
  495.         clr.w   BreakStatus
  496. ChangePosition:
  497.         clr.l   OffsetBlock             ; offset block = 0
  498.         move.w  NewPosJump,CurrentPos
  499.         addq.w  #1,CurrentPos           ; new position
  500.         move.w  sng_Len(a6),d0
  501.         move.w  CurrentPos,d1
  502.         cmp.w   d0,d1                   ; end of song ?
  503.         bne.s   PlaySoundEnd
  504.         clr.w   CurrentPos              ; position = 0
  505. PlaySoundEnd:
  506.         rts
  507.  
  508. PlayInstr:
  509.         lea     sng_Instr0(a6),a2
  510.         move.l  0(a0,d1.l),ad_SampPer(a4)
  511.         addq.l  #NEXTTRACK,d1
  512.         moveq   #0,d0
  513.         move.b  ad_SampPer(a4),d0
  514.         lsr.b   #3,d0                   ; d0 = instrument number
  515.         tst.b   d0                      ; d0 == 0 ?
  516.         beq.s   NoSampleChange
  517.  
  518.         lea     SampleAdrTable,a5
  519.         subq.b  #1,d0
  520.         move.l  d0,d3
  521.         lsl.w   #2,d0                   ; d0 = SampleAdrTable offset
  522.         mulu    #SIZEOF_insdt,d3
  523.         add.l   #instr_Start,d3
  524.         add.l   d3,a2                   ; a2 -> Start InstrData
  525.         move.l  0(a5,d0.w),d4
  526.         add.l   (a2)+,d4                ; Start
  527.         move.l  d4,ad_SmpAdr(a4)
  528.         beq.s   NoSampleChange
  529.         move.w  (a2)+,ad_SmpLen(a4)     ; Len
  530.         move.l  (a2)+,d5                ; RStart
  531.         move.w  (a2)+,d2                ; RLen
  532.         bne.s   SetRepeat
  533.         moveq   #1,d2
  534.         moveq   #0,d5
  535. SetRepeat:
  536.         move.w  d2,ad_RepLen(a4)
  537.         add.l   ad_SmpAdr(a4),d5
  538.         move.l  d5,ad_RepAdr(a4)
  539.         move.w  (a2),ad_Volume(a4)      ; Volume
  540. NoSampleChange:
  541.         move.w  ad_SampPer(a4),d6
  542.         and.w   #$7ff,d6                ; note == 0 ?
  543.         beq.s   TestEffects
  544.         move.w  d6,ad_ArpPer(a4)
  545.         move.w  ad_DMABit(a4),d0
  546.         move.w  d0,DMACON               ; cut DMA audio for this track
  547.  
  548.         move.b  CIABCRA,d2              ; wait loop
  549.         move.b  d2,d3
  550.         and.b   #%11000000,d3
  551.         or.b    #%00001000,d3
  552.         move.b  d3,CIABCRA
  553.         move.b  #$2f,CIABTALO
  554.         move.b  #1,CIABTAHI
  555. PlayDelay2:
  556.         btst.b  #0,CIABCRA
  557.         bne.s   PlayDelay2
  558.         move.b  d2,CIABCRA
  559.         move.b  #%00000001,CIABICR
  560.  
  561.         cmp.w   #STOP,d6                ; note == 'OFF' ?
  562.         bne.s   SetPlayRegs
  563.         clr.w   AUDxVOL(a3)             ; set audio volume to 0
  564.         or.w    d0,AudioDMA
  565.         rts
  566.  
  567. SetPlayRegs:
  568.         move.l  ad_SmpAdr(a4),(a3)      ; sample address == NULL ?
  569.         beq.s   TestEffects
  570.         move.w  ad_SmpLen(a4),AUDxLEN(a3)
  571.         move.w  d6,AUDxPER(a3)
  572.         or.w    d0,AudioDMA
  573.         move.w  d6,ad_PitchPer(a4)
  574. TestEffects:
  575.         move.b  ad_Effet(a4),d0         ; d0 = effect
  576.         bsr.s   EffVolume
  577.         tst.b   d0
  578.         beq.s   TestEffectsEnd
  579.         cmp.b   #FILTER,d0
  580.         beq     EffFilter
  581.         cmp.b   #MASTERVOL,d0
  582.         beq.s   EffMaster
  583.         cmp.b   #TEMPO,d0
  584.         beq.s   EffSpeed
  585.         cmp.b   #JUMP,d0
  586.         beq.s   EffJump
  587. TestEffectsEnd:
  588.         rts
  589.  
  590. EffVolume:                              ; modify volume
  591.         cmp.w   #VOLUME,d0
  592.         bne.s   UseInstrVol
  593.         moveq   #0,d2
  594.         move.b  ad_Info(a4),d2          ; d0 = new volume
  595.         bra.s   SetInstrVol
  596. UseInstrVol:
  597.         tst.w   d6
  598.         beq.s   EffVolumeEnd
  599.         move.w  ad_Volume(a4),d2
  600. SetInstrVol:
  601.         sub.w   MasterVolume,d2         ; new volume - master >= 0
  602.         bge.s   SetVolumeReg
  603.         moveq   #0,d2                   ; new volume = 0
  604. SetVolumeReg:
  605.         move.w  d2,AUDxVOL(a3)          ; new volume into audio reg
  606. EffVolumeEnd:
  607.         rts
  608.  
  609. EffMaster:                              ; modify master volume
  610.         moveq   #MAX_VOL,d2
  611.         move.b  ad_Info(a4),d0
  612.         sub.b   d0,d2
  613.         blt.s   EffMasterEnd
  614.         move.b  d2,MasterVolume+1
  615. EffMasterEnd:
  616.         rts
  617.  
  618. EffSpeed:                               ; modify tempo
  619.         move.b  ad_Info(a4),d0
  620.         beq.s   EffSpeedEnd
  621.         clr.w   PlayTimer
  622.         move.b  d0,sng_Tempo+1(a6)
  623. EffSpeedEnd:
  624.         rts
  625.  
  626. EffJump:                                ; jump or break
  627.         move.w  #1,BreakStatus
  628.         move.b  ad_Info(a4),d0
  629.         cmp.b   #BREAK,d0
  630.         beq.s   EffBreak
  631.         subq.b  #2,d0
  632.         ext.w   d0
  633.         move.w  d0,NewPosJump
  634.         rts
  635. EffBreak:
  636.         move.w  CurrentPos,NewPosJump
  637.         rts
  638.  
  639. EffFilter:                              ; filter on/off
  640.         move.b  ad_Info(a4),d0
  641.         bne.s   SetFilter
  642.         bset    #1,CIAAPRA
  643.         rts
  644. SetFilter:
  645.         bclr    #1,CIAAPRA
  646.         rts
  647.  
  648.         data    __MERGED
  649.  
  650. CiabBase:       dc.l    0
  651. IsNTSC:         dc.w    0
  652.  
  653. CiabName:       dc.b    'ciab.resource',0
  654. TimerIntName:   dc.b    'DSS Tracker Player',0
  655.                 cnop    0,2
  656.  
  657. TimerInt:
  658.         dc.l  0                 ; Interrupt.is_Node.ln_Succ
  659.         dc.l  0                 ; Interrupt.is_Node.ln_Pred
  660.         dc.b  2                 ; Interrupt.is_Node.ln_Type = NT_INTERRUPT
  661.         dc.b  -10               ; Interrupt.is_Node.ln_Pri
  662.         dc.l  TimerIntName      ; Interrupt.is_Node.ln_Name
  663.         dc.l  0                 ; Interrupt.is_Data
  664.         dc.l  TimerIntRoutine   ; Interrupt.is_Code
  665.  
  666. clrstart
  667.  
  668. PlayOn:         dc.w    0
  669. PlayTimer:      dc.w    0
  670. CurrentPos:     dc.w    0
  671. OffsetBlock:    dc.l    0
  672. AudioDMA:       dc.w    0
  673. MasterVolume:   dc.w    0
  674. BreakStatus:    dc.w    0
  675. NewPosJump:     dc.w    0
  676.  
  677. clrend
  678.  
  679. ChannelData0:
  680.         dc.w    0               ; Period                0
  681.         dc.w    0               ; Sample+Info           2
  682.         dc.w    0               ; Volume                4
  683.         dc.l    0               ; Sample address        6
  684.         dc.w    0               ; Sample length        10
  685.         dc.l    0               ; Repeat address       12
  686.         dc.w    0               ; Repeat length        16
  687.         dc.w    0               ; Shazam period        18
  688.         dc.w    1               ; DMA bit              20
  689.         dc.w    0               ; Pitch  period        22
  690. ChannelData1:
  691.         ds.w    10
  692.         dc.w    2
  693.         dc.w    0
  694. ChannelData2:
  695.         ds.w    10
  696.         dc.w    4
  697.         dc.w    0
  698. ChannelData3:
  699.         ds.w    10
  700.         dc.w    8
  701.         dc.w    0
  702.  
  703.         dc.w    1712
  704. NoteTable:
  705.         dc.w    1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,906
  706.         dc.w    856,808,762,720,678,640,604,570,538,508,480,453
  707.         dc.w    428,404,381,360,339,320,302,285,269,254,240,226
  708.         dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  709.         dc.w    113,113,113,113,113,113,113,113,113,113,113,113
  710.         dc.w    113,113,113,113,113,113,113,113,113,113,113,113
  711.         dc.w    113,113,113,113,113,113
  712.  
  713. TimerTable:     dc.w    14187,14318
  714.  
  715. SampleAdrTable: ds.l    31
  716.  
  717. name    dc.b    "Digital Sound Studio",0
  718.  
  719.         end
  720.